/**
 * @file init.h
 * @brief System Initializer Interface
 *
 * This module supplies hooks to the system and devices
 * initializer. It also groups the flash entries, IO
 * device entries, and file system entries to the specific
 * seciton
 *
 * @author yemt@witsi.cn
 * @date 2011-07-29
 * @version rxSys.init.01
 */
#ifndef INIT_H_
#define INIT_H_

typedef int (*initcall_t)(void);        /**< Initializer Type */

#define likely(x)               __builtin_expect(!!(x), 1)
#define unlikely(x)             __builtin_expect(!!(x), 0)

#define __define_initcall(level,fn,id) \
        static const initcall_t __initcall_##fn##id \
        __attribute__((__used__, section(".initcall" level ".init"))) = fn

#define __flashdrv_entry        __attribute__((__used__, section(".device.flash")))
#define __iodev_entry           __attribute__((__used__, section(".device.io")))
#define __file_sys_entry        __attribute__ ((__used__,section (".filesys")))


#define init_initcall(fn)       __define_initcall("1",fn,1)
#define arch_initcall(fn)       __define_initcall("2",fn,2)
#define board_initcall(fn)      __define_initcall("3",fn,3)
#define device_initcall(fn)     __define_initcall("4",fn,4)
#define late_initcall(fn)       __define_initcall("5",fn,5)

#endif /* INIT_H_ */
